<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="box"></div><button class="btn">点我啊</button>

    <script>
        let btn = document.querySelector(".btn");
        btn.onclick = () => {
            let xhr = new XMLHttpRequest();
            xhr.open("get", "./1.php");
            xhr.send();
            xhr.onreadystatechange = () => {
                if (xhr.readyState === 4) {
                    let json = JSON.parse(xhr.responseText);
                    let box = document.querySelector(".box");
                    json.forEach((item, index) => {
                        box.innerHTML += `<li>
                            <img src="${item.img}">
                            <p>${item.title}</p>
                        </li>`
                    })
                }
            }
        }
    </script>
</body>

</html>